/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#ifndef _BF_RUNNING_STATE_APP_H_
#define _BF_RUNNING_STATE_APP_H_

#include "IBFStateApp.h"
#include "BFArgorithmContainer.h"

#ifndef _BRICKOS_
#include "ISimulatorControl.h"
#endif

class BFRunningStateApp : public IBFStateApp
{
public:
//	BFRunningStateApp(int noOfPathRecognizer, int noOfDriveControl, IBFLog* log);
	BFRunningStateApp(BFArgorithmContainer* ac);
	virtual ~BFRunningStateApp(void);

	int execEntry(BFState* state);
	int execDo(BFState* state);
	int execExit(BFState* state);

	void setStrategyArgorithm(IBFArgorithm* argo) { strategyArgorithm = argo; }
	void setArgorithm(BFPathRecognizer* argo) { currentPathRecognizer = argo; }
	void setArgorithm(BFDriveControl* argo) { currentDriveControl = argo; }

//	BFArgorithmContainer* getArgorithms() { return &argorithmContainer; }

#ifndef _BRICKOS_
	void setSimulatorControl(ISimulatorControl* sc=0) { simCon=sc; }
#endif

protected:
	// this method is called in execEntry()
	virtual int setup(BFState* state) { return -1; }

	// this method is called in the loop of execDo() calling
	// if pre is true then the call is the one before drive
	// should return 0 if running continues
	// should return 1 if running will be end
	virtual int judge(bool pre, unsigned int loopTick, BFState* state) {return -1; }
	virtual int update(unsigned int loopTick, BFState* state) {return -1;}
	virtual int drive(unsigned int loopTick, BFState* state) {return -1; }

	// this method is called in exitEntry()
	virtual int cleanup(BFState* state) { return -1; }



protected:
	IBFArgorithm* strategyArgorithm;

	BFArgorithmContainer* argorithmContainer;
	BFPathRecognizer* currentPathRecognizer;
	BFDriveControl* currentDriveControl;
	unsigned int loopCounter;

#ifndef _BRICKOS_
	ISimulatorControl* simCon;
#endif

};

#endif // _BF_RUNNING_STATE_APP_H_
